#include "aTcpServer.h"
#include <QDebug>
#include <QMessageBox>
#include "dialog.h"
#include "ui_dialog.h"
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include "DBO/protocolconversion.h"
#include "macro.h"

aTcpServer::aTcpServer(QObject *parent) :
    QTcpServer(parent)
{
    socketSend=NULL;
    numOfConnection=0;
}

void aTcpServer::incomingConnection(int socketId)
{
    numOfConnection++;

    tcpClientSocket *socket=new tcpClientSocket(this);
    socket->setSocketDescriptor(socketId);
    socket->myPeerAddr=socket->peerAddress();
    socket->myPeerPort=socket->peerPort();

    socketSend=socket; //(暂时不用)网关节点和中间件会建立两条Tcp连接，第二条连接的方向是从中间件到网关

    emit sigErrorInfo("Tcp connected");
#ifdef debu
    qDebug()<<"Tcp connected";
#endif
    qApp->beep(); //有新的Tcp连接时，蜂鸣器响

}


aTcpServer::~aTcpServer()
{
    close();
    //delete queryForMultimedia;  //如果不注释掉这句，会出错。原因应该是tcpClientscoket会使用这个来作最后的清理工作
}
